package com.zzl.rabbitmq.work;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.zzl.rabbitmq.utils.RabbitMqUtils;

/**
 * Title: Worker01.class<br>
 * Description: <br>
 * Copyright (c)  2021    <br>
 * Create DateTime: 2021/7/1 15:21 <br>
 *
 * @author zhuangzhuangliang
 */
public class Worker01 {

    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception{

        Channel channel = RabbitMqUtils.getChannel();
        //生产消息
        DeliverCallback deliverCallback = (consumerTag, message) ->{
            String msg = new String(message.getBody());
            System.out.println(msg);
        };

        CancelCallback cancelCallback = consumerTag ->{
            System.out.println("消息中断");
        };

        channel.basicConsume(QUEUE_NAME,deliverCallback,cancelCallback);
    }
}
